// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class QBP_K13 : AbstractMessage
    {
		/// Constructor
		public QBP_K13() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "QBP", TriggerEvent = "K13" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("MSA",2)]
  	    [HL7Field(HL7Version.v24, 2, HL7Repeat.False, HL7Required.True,"MSA")]
  	    [HL7Field(HL7Version.v25, 2, HL7Repeat.False, HL7Required.True,"MSA")]
	    public MSA MSA {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("ERR",4)]
  	    [HL7Field(HL7Version.v24, 4, HL7Repeat.False, HL7Required.False,"ERR")]
  	    [HL7Field(HL7Version.v25, 4, HL7Repeat.False, HL7Required.False,"ERR")]
	    public ERR ERR {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("QAK",6)]
  	    [HL7Field(HL7Version.v24, 6, HL7Repeat.False, HL7Required.True,"QAK")]
  	    [HL7Field(HL7Version.v25, 6, HL7Repeat.False, HL7Required.True,"QAK")]
	    public QAK QAK {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("QPD",7)]
  	    [HL7Field(HL7Version.v24, 7, HL7Repeat.False, HL7Required.True,"QPD")]
  	    [HL7Field(HL7Version.v25, 7, HL7Repeat.False, HL7Required.True,"QPD")]
	    public QPD QPD {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("ROW_DEFINITION",8)]
  	    [HL7Field(HL7Version.v24, 8, HL7Repeat.False, HL7Required.False,"ROW_DEFINITION_QBP_K13")]
  	    [HL7Field(HL7Version.v25, 8, HL7Repeat.False, HL7Required.False,"ROW_DEFINITION_QBP_K13")]
	    public ROW_DEFINITION_QBP_K13 ROW_DEFINITION {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("DSC",17)]
  	    [HL7Field(HL7Version.v24, 17, HL7Repeat.False, HL7Required.False,"DSC")]
  	    [HL7Field(HL7Version.v25, 17, HL7Repeat.False, HL7Required.False,"DSC")]
	    public DSC DSC {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v24 == options.Version) {
		 MSA = PopSegmentParseAndCheckRequired<MSA>(availableData, options, "MSA");
		 ERR = PopSegmentParseAndCheckRequired<ERR>(availableData, options, "ERR");
		 QAK = PopSegmentParseAndCheckRequired<QAK>(availableData, options, "QAK");
		 QPD = PopSegmentParseAndCheckRequired<QPD>(availableData, options, "QPD");
		 ROW_DEFINITION = ProcessGroup<ROW_DEFINITION_QBP_K13>(availableData, options, "ROW_DEFINITION");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
		if (HL7Version.v25 == options.Version) {
		 MSA = PopSegmentParseAndCheckRequired<MSA>(availableData, options, "MSA");
		 ERR = PopSegmentParseAndCheckRequired<ERR>(availableData, options, "ERR");
		 QAK = PopSegmentParseAndCheckRequired<QAK>(availableData, options, "QAK");
		 QPD = PopSegmentParseAndCheckRequired<QPD>(availableData, options, "QPD");
		 ROW_DEFINITION = ProcessGroup<ROW_DEFINITION_QBP_K13>(availableData, options, "ROW_DEFINITION");
		 DSC = PopSegmentParseAndCheckRequired<DSC>(availableData, options, "DSC");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "QBP_K13";
			}
        }

        static QBP_K13() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(QBP_K13));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (MSA != null) {
				segmentData.Add(MSA.GetER7(options));
			}
			if (ERR != null) {
				segmentData.Add(ERR.GetER7(options));
			}
			if (QAK != null) {
				segmentData.Add(QAK.GetER7(options));
			}
			if (QPD != null) {
				segmentData.Add(QPD.GetER7(options));
			}
			if (ROW_DEFINITION != null) {
				segmentData.Add(ROW_DEFINITION.GetER7(options));
			}
			if (DSC != null) {
				segmentData.Add(DSC.GetER7(options));
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

